{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(5, 2)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "-1"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import cv2\n",
    "import numpy as np\n",
    "newImageInfo = (500,500,3)\n",
    "dstImg = np.zeros(newImageInfo,np.uint8)\n",
    "# 绘制矩形\n",
    "# 参数1：目标图片数据 参数2：绘制的初始位置 参数3：绘制的结束位置 参数4：颜色(b,g,r) \n",
    "# 参数5：是否需要填充，若填充为-1，若为其他数字则表示线条宽度\n",
    "cv2.rectangle(dstImg,(50,100),(200,300),(255,0,0),1)\n",
    "# 绘制圆形 参数2：圆心 参数3：半径 其余与矩形API参数一致\n",
    "cv2.circle(dstImg,(250,250),(50),(0,255,0),2)\n",
    "# 绘制椭圆形 参数3：轴的长度（长轴和短轴） 参数4：偏转角度 参数5：圆弧的起始角度 参数6：圆弧的结束角度\n",
    "cv2.ellipse(dstImg,(256,256),(150,100),0,0,180,(0,0,255),1)\n",
    "# 绘制任意多边形\n",
    "points = np.array([[150,50],[140,140],[200,170],[250,250],[150,50]],np.int32)\n",
    "print(points.shape)\n",
    "#points = points.reshape((-1,1,2))\n",
    "cv2.polylines(dstImg,[points],True,(0,255,255))\n",
    "cv2.imshow('dstImg',dstImg)\n",
    "cv2.waitKey(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
